﻿using System;
using System.Runtime.InteropServices;
using DirectShowLib;

namespace MediaBridge 
{
    /// <summary>
    /// The MediaBridge source filter COM interface
    /// </summary>
    [ComImport, Guid("FDDEB397-2169-4441-B924-E6991F4A0431"),
     InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IMediaBridgeSourceFilter
    {
        int InitializeVideo(int VideoPixelWidth,
                            int VideoPixelHeight,
                            int BitCount,
                            int FourCC,
                            [Out, MarshalAs(UnmanagedType.Struct)]Guid MediaSubType);

        int SetCallback(IMediaBridgeCallback Callback);
    }

    /// <summary>
    /// The callback interface for the source filter
    /// </summary>
    [ComImport, Guid("FDDEB397-2269-4441-B924-E6991F4A0431"),
     InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IMediaBridgeCallback
    {
        [PreserveSig]
        int FillBuffer(IMediaSample pSample);
    }

    /// <summary>
    /// Standard bitmap compression options
    /// </summary>
    public enum BitmapCompression
    {
        UncompressedRGB = 0,
        RLE8 = 1,
        RLE4 = 2,
        BitFields = 3,
        JPEG = 4,
        PNG = 5
    }

    /// <summary>
    /// Supported media types for samples.  These values can be passed for the MediaType
    /// parameter of the InitializeVideo method in the VideoRendererElement
    /// </summary>
    public static class RendererMediaType
    {
        public static readonly Guid A2B10G10R10 = new Guid(0x576f7893, 0xbdf6, 0x48c4, 0x87, 0x5f, 0xae, 0x7b, 0x81, 0x83, 0x45, 0x67);
        public static readonly Guid A2R10G10B10 = new Guid(0x2f8bb76d, 0xb644, 0x4550, 0xac, 0xf3, 0xd3, 12, 170, 0x65, 0xd5, 0xc5);
        public static readonly Guid ARGB1555 = new Guid(0x297c55af, 0xe209, 0x4cb3, 0xb7, 0x57, 0xc7, 0x6d, 0x6b, 0x9c, 0x88, 0xa8);
        public static readonly Guid ARGB1555_D3D_DX7_RT = new Guid(0x35314137, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid ARGB1555_D3D_DX9_RT = new Guid(0x35314139, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid ARGB32 = new Guid(0x773c9ac0, 0x3274, 0x11d0, 0xb7, 0x24, 0, 170, 0, 0x6c, 0x1a, 1);
        public static readonly Guid ARGB32_D3D_DX7_RT = new Guid(0x38384137, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid ARGB32_D3D_DX9_RT = new Guid(0x38384139, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid ARGB4444 = new Guid(0x6e6415e6, 0x5c24, 0x425f, 0x93, 0xcd, 0x80, 0x10, 0x2b, 0x3d, 0x1c, 0xca);
        public static readonly Guid ARGB4444_D3D_DX7_RT = new Guid(0x34344137, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid ARGB4444_D3D_DX9_RT = new Guid(0x34344139, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid RGB1 = new Guid(0xe436eb78, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB16_D3D_DX7_RT = new Guid(0x36315237, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid RGB16_D3D_DX9_RT = new Guid(0x36315239, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid RGB24 = new Guid(0xe436eb7d, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB32 = new Guid(0xe436eb7e, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB32_D3D_DX7_RT = new Guid(0x32335237, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid RGB32_D3D_DX9_RT = new Guid(0x32335239, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid RGB4 = new Guid(0xe436eb79, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB555 = new Guid(0xe436eb7c, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB565 = new Guid(0xe436eb7b, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid RGB8 = new Guid(0xe436eb7a, 0x524f, 0x11ce, 0x9f, 0x53, 0, 0x20, 0xaf, 11, 0xa7, 0x70);
        public static readonly Guid Y211 = new Guid(0x31313259, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid Y411 = new Guid(0x31313459, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid Y41P = new Guid(0x50313459, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid YUY2 = new Guid(0x32595559, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid YUYV = new Guid(0x56595559, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid YV12 = new Guid(0x32315659, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid YVU9 = new Guid(0x39555659, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
        public static readonly Guid YVYU = new Guid(0x55595659, 0, 0x10, 0x80, 0, 0, 170, 0, 0x38, 0x9b, 0x71);
    }
}
